/*
 * @Author: your name
 * @Date: 2021-11-01 15:58:05
 * @LastEditTime: 2021-11-08 17:44:52
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \star-cat-h5\vue.config.js
 */
const vConsolePlugin = require('vconsole-webpack-plugin')
// const API = require('./src/axios/https')
module.exports = {
  //基本路径
  publicPath: './', ///默认的'/'是绝对路径，如果不确定在根路径，改成相对路径'./'
  // 输出文件目录
  outputDir: 'dist',
  assetsDir: 'static',
  indexPath: 'index.html',
  devServer: {
    open: true,
    host: "0.0.0.0",
    port: 8080, // 端口号
    https: true,
    open: true, //配置自动启动浏览器
    //以上的ip和端口是我们本机的;下面为需要跨域的
    proxy: { //配置跨域
      '/api': {
        // target: API.APIURL,
        target: process.env.VUE_APP_WX_BASE_API,
        ws: true,
        changOrigin: true, //允许跨域
        pathRewrite: {
          '/api': '' //请求的时候使用这个api就可以
        }
      },
      '/oss': {
        target: 'https://ost-app-img.oss-cn-beijing.aliyuncs.com',
        ///测试DEMO
        //  target:'https://ost-app-img-dev.oss-cn-beijing.aliyuncs.com',
        changeOrigin: true,
        ws: true,
        pathRewrite: {
          '^/oss': ''
        }
      },
    }
  },
  configureWebpack:config => {
    //生产环境去掉vconsole调试器
    let envType = process.env.VUE_APP_ENV != 'prod'
    // let envType = true;
    let pluginsDev = [
        new vConsolePlugin({
            filter: [],
            enable: envType
        })
    ]
    config.plugins = [...config.plugins, ...pluginsDev]
  }
}